package com.xxwy.protocal;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

/**
 * @author wy
 * @date 2020/3/8 23:59
 */
public class XxwyDecoder extends ReplayingDecoder<XxwyProtocol> {
  @Override
  protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
    int len = byteBuf.readInt();
    byte[] bytes = new byte[len];
    byteBuf.readBytes(bytes);
    XxwyProtocol xxwYprotocol = new XxwyProtocol(len,bytes);
    list.add(xxwYprotocol);
  }
}
